import axios from "axios";

// 引入进度条插件nProgress
import nProgress from 'nprogress';
// 进度条插件样式
import "nprogress/nprogress.css";

// 创建模拟数据实例对象
let mockRequests = axios.create({
    baseURL: "/mock",
    timeout: 5000
});

// 请求拦截器
mockRequests.interceptors.request.use(config => {
    nProgress.start();
    return config;
});

// 响应拦截器
mockRequests.interceptors.response.use((res) => {
    nProgress.done();
    return res.data;
}, (err) => {
    alert(err.message);
    return new Promise(err.message);
});

// 向外共享模拟数据实例对象
export default mockRequests;



